// var i;
// var $bundleConfig = require("./BundleConfig");
// var $logManager = require("./LogManager");
// var $resKeeper = require("./ResKeeper");
// var $commonUtils = require("./CommonUtils");
// var $uI_Player_UIBindings = require("./UI_Player_UIBindings");
// var $playerDataManager = require("./PlayerDataManager");
// var $excel = require("./Excel");
// var $excelUtil = require("./ExcelUtil");
// var $gameGlobalVariable = require("./GameGlobalVariable");
// var $nodePoolMag = require("./NodePoolMag");
// var $uI_Bullet = require("./UI_Bullet");
// var $uI_BulletBomb = require("./UI_BulletBomb");
// var $buffMag = require("./BuffMag");
// var $uI_MosterLogic = require("./UI_MosterLogic");
// var M = cc._decorator;
// var E = M.ccclass;
// var x = M.property;
// var C = M.inspector;
// var B = (function (e) {
//     function t() {
//         var t = (null !== e && e.apply(this, arguments)) || this;
//         t.auto_ui = null;
//         t.playerId = 1;
//         t.playimg = null;
//         t.eff1 = null;
//         t.eff2 = null;
//         t.sgattack = 0;
//         t.sgattackspeed = 0;
//         t.sgbaojilv = 0;
//         t.sgbaojia = 0;
//         t.sgattacktype = 1;
//         t.sgattacktagtype = -1;
//         t.sgtianfuid = -1;
//         t.kuangrePlayer = null;
//         t.buffid = -1;
//         t.xiaolajiao = null;
//         t.mosterNodes = null;
//         t.playerInfo = null;
//         t.kuangReParNode = null;
//         t.leveliconspr = null;
//         t.nowattackindex = 0;
//         t.kuangReEffNode = null;
//         t.attacktime = 0;
//         t.kuangretime = 0;
//         t.offkuangretime = 0;
//         t.kuangreisOver = !1;
//         t.playerpuase = !1;
//         t.issend = !1;
//         t.ismove = !1;
//         return t;
//     }
//     __extends(t, e);
//     t.prototype.onEnable = function () {
//         this.xiaolajiao = this.node.getChildByName("xialajiao");
//         this.xiaolajiao.active = !1;
//     };
//     t.prototype.onClickPlayer = function () {};
//     t.prototype.onDisable = function () {
//         this.cleanKuangReEff();
//         this.kuangrePlayer = null;
//         $buffMag.BuffMgr.clearPlayerSendCount(this);
//         this.attacktime = 0;
//     };
//     t.prototype.initPlayerInfo = function (e, t) {
//         return __awaiter(this, void 0, void 0, function () {
//             var o;
//             var n;
//             return __generator(this, function () {
//                 this.kuangReParNode = this.node.getChildByName("kuangreNode");
//                 this.mosterNodes = e;
//                 this.playerInfo = t;
//                 if (this.eff1 && this.eff2) {
//                     4 == this.playerInfo.equipLevel
//                         ? (this.eff1.active = this.eff2.active = !0)
//                         : (this.eff1.active = this.eff2.active = !1);
//                 }
//                 o = 1e3 + this.playerId;
//                 n = $excel.Excel.shuiguo(o);
//                 $logManager.LogMgr.debug("水果信息", n);
//                 this.sgattack = n.attack;
//                 this.sgattackspeed = n.attackspeed;
//                 this.sgbaojilv = n.baojilv;
//                 this.sgbaojia = n.baojivalue;
//                 this.sgattacktype = n.attacktype;
//                 this.sgattacktagtype = n.attackstate;
//                 this.waibuleveladd();
//                 this.hechengAdd();
//                 this.sgtianfuid = n.talent;
//                 this.initUi();
//                 return [2];
//             });
//         });
//     };
//     t.prototype.waibuleveladd = function () {
//         if (this.playerInfo) {
//             var e = $excelUtil.ExcelUtil.getSameData($excel.Excel.shuiguolevel_all, "shuiguoId", this.playerId + 1e3);
//             var t = $playerDataManager.PlayerDataMgr.GetEquipDataById(this.playerId + 1e3).level;
//             var o = 0;
//             var n = 0;
//             for (var i = 0; i < e.length; i++) {
//                 if (i + 1 <= t && i > 0) {
//                     o += e[i - 1].addattack;
//                     n += e[i - 1].addAtkSpeed;
//                 }
//             }
//             this.sgattack = this.sgattack + o;
//             this.sgattackspeed = this.sgattackspeed - n;
//         }
//     };
//     t.prototype.hechengAdd = function () {
//         if (this.playerInfo) {
//             var e = $excelUtil.ExcelUtil.getSameData($excel.Excel.shuiguohecheng_all, "shuiguoId", this.playerId + 1e3)[
//                 this.playerInfo.equipLevel
//             ];
//             if (e) {
//                 this.sgattack = this.sgattack + (this.sgattack * e.addattack) / 100;
//                 this.sgattackspeed = this.sgattackspeed / (1 + e.addattackspeed / 100);
//             }
//         }
//     };
//     t.prototype.getNowHechengLevel = function () {
//         if (this.playerInfo) {
//             var e = $excelUtil.ExcelUtil.getSameData($excel.Excel.shuiguohecheng_all, "shuiguoId", this.playerId + 1e3);
//             if (e) {
//                 return e[this.playerInfo.equipLevel];
//             }
//         }
//     };
//     t.prototype.initUi = function () {
//         return __awaiter(this, void 0, void 0, function () {
//             var e;
//             var t;
//             var o;
//             return __generator(this, function (n) {
//                 switch (n.label) {
//                     case 0:
//                         if (this.playerInfo) {
//                             return [
//                                 4,
//                                 this._loadRes(
//                                     $bundleConfig.BundleNames.Common,
//                                     "res/player/player" + this.playerId + "_" + (this.playerInfo.equipLevel + 1),
//                                     cc.SpriteFrame
//                                 )
//                             ];
//                         } else {
//                             return [2];
//                         }
//                     case 1:
//                         e = n.sent();
//                         this.playimg.spriteFrame = e;
//                         this.leveliconspr = this.node.getChildByName("levelicon").getComponent(cc.Sprite);
//                         t = ["小牌子", "小牌子-1", "小牌子-2", "小牌子-3", "xiaowu"];
//                         return [
//                             4,
//                             this._loadRes(
//                                 $bundleConfig.BundleNames.Common,
//                                 "res/player/" + t[this.playerInfo.equipLevel],
//                                 cc.SpriteFrame
//                             )
//                         ];
//                     case 2:
//                         o = n.sent();
//                         this.leveliconspr.spriteFrame = o;
//                         return [2];
//                 }
//             });
//         });
//     };
//     t.prototype.getAttackTag = function (e) {
//         var t = null;
//         if (!this.mosterNodes) {
//             if ((i = $gameGlobalVariable.GameGlobalVariable.mosterNode).children.length > 0) {
//                 return i.children[0];
//             } else {
//                 return t;
//             }
//         }
//         if (this.mosterNodes.children.length > 0) {
//             var o = null;
//             switch (e) {
//                 case 4:
//                     for (var n = this.mosterNodes.children, i = null, a = 0; a < n.length; a++) {
//                         var r = n[a].getComponent($uI_MosterLogic.default);
//                         if (1 == r.nowmosterdata.boss) {
//                             i = r;
//                             break;
//                         }
//                     }
//                     if (i) {
//                         t = i.node;
//                     } else {
//                         if ((o = $gameGlobalVariable.GameGlobalVariable.paixuMoster(this.mosterNodes)).length > 0) {
//                             t = o[0].script.node;
//                         }
//                     }
//                     break;
//                 case 1:
//                     if ((o = $gameGlobalVariable.GameGlobalVariable.paixuMoster(this.mosterNodes)).length > 0) {
//                         t = o[0].script.node;
//                     }
//                     break;
//                 case 2:
//                     if ((o = $gameGlobalVariable.GameGlobalVariable.paixuMoster(this.mosterNodes)).length > 0) {
//                         t = o[$commonUtils.default.limitInteger(0, o.length - 1)].script.node;
//                     }
//                     break;
//                 case 3:
//                     if ((o = $gameGlobalVariable.GameGlobalVariable.paixuMoster(this.mosterNodes)).length > 0) {
//                         var c = o[this.nowattackindex];
//                         if (!c) {
//                             this.nowattackindex = 0;
//                             c = o[this.nowattackindex];
//                         }
//                         t = c.script.node;
//                         this.nowattackindex += 1;
//                     }
//                     if (!t) {
//                         var s = null;
//                         for (a = 0; a < o.length && !(s = o[a]); a++) {}
//                         if (s) {
//                             t = s.script.node;
//                         }
//                     }
//                     break;
//                 case 8:
//                 case 5:
//                     break;
//                 default:
//                     if ((o = $gameGlobalVariable.GameGlobalVariable.paixuMoster(this.mosterNodes)).length > 0) {
//                         t = o[0].script.node;
//                     }
//             }
//         }
//         return t;
//     };
//     t.prototype.sendAttack = function () {
//         var e = this;
//         var t = this.getAttackTag(this.sgattacktagtype);
//         if (t) {
//             cc.tween(this.playimg.node)
//                 .to(0.1, {
//                     scaleY: 1.3,
//                     scaleX: 1.1
//                 })
//                 .to(0.1, {
//                     scale: 1
//                 })
//                 .start();
//             var o = $buffMag.BuffMgr.playerAttackFangshiIng(this, this.sgattacktype);
//             var n = $buffMag.BuffMgr.playAttackJiaCheng(this, this.sgattack, 1);
//             var i = $buffMag.BuffMgr.getAttackBaoJi(this);
//             var a = this.sgbaojilv + i.baojijilv;
//             var r = this.sgbaojia + i.baojijiacheng;
//             var c = !1;
//             if (Math.random() <= a) {
//                 c = !0;
//                 n *= r;
//             }
//             if ($buffMag.BuffMgr.getLianXuAttack(this)) {
//                 this.scheduleOnce(function () {
//                     e.sendBullet(o, n, t, c);
//                 }, 0.1);
//             }
//             this.sendBullet(o, n, t, c);
//         }
//     };
//     t.prototype.sendAttackMove = function () {
//         if (this.mosterNodes.children.length >= 1) {
//             var e = $buffMag.BuffMgr.playAttackJiaCheng(this, this.sgattack, 1);
//             this.createBulletMove(e);
//         }
//     };
//     t.prototype.sendAttackBomb = function () {
//         if (this.mosterNodes.children.length >= 1) {
//             cc.tween(this.playimg.node)
//                 .to(0.1, {
//                     scaleY: 1.1
//                 })
//                 .to(0.1, {
//                     scaleY: 1
//                 })
//                 .start();
//             var e = $buffMag.BuffMgr.playAttackJiaCheng(this, this.sgattack, 1);
//             var t = this.getBulletBombPos();
//             if (t) {
//                 this.createBulletBomb(e, t);
//             }
//         }
//     };
//     t.prototype.sendBullet = function (e, t, o, n) {
//         switch (e) {
//             case 1:
//                 this.createBullet(t, o, 1, n);
//                 break;
//             case 2:
//                 for (var i = $gameGlobalVariable.GameGlobalVariable.paixuMoster(this.mosterNodes), a = 0; a < 3; a++) {
//                     var r = i[a];
//                     if (r) {
//                         this.createBullet(t, r.script.node, a + 1, n);
//                     }
//                 }
//         }
//     };
//     t.prototype.getBulletBombPos = function () {
//         cc.v2();
//         var e = $gameGlobalVariable.GameGlobalVariable.paths.children;
//         var t = [];
//         for (var o = 0; o < e.length - 1; o++) {
//             var n = e[o];
//             var i = e[o + 1];
//             var a = 0;
//             if (0 == o) {
//                 a = -100;
//             }
//             var r = 0;
//             if (o + 1 == 5) {
//                 r = 100;
//             }
//             var c = $commonUtils.default.getRandomInt(n.x + a, i.x + r);
//             var s = $commonUtils.default.getRandomInt(n.y, i.y);
//             t.push({
//                 x: c,
//                 y: s
//             });
//         }
//         return t[$commonUtils.default.getRandomInt(0, t.length - 1)];
//     };
//     t.prototype.createBulletMove = function (e) {
//         return __awaiter(this, void 0, void 0, function () {
//             var t;
//             var o;
//             var n;
//             var i;
//             return __generator(this, function () {
//                 t = $buffMag.BuffMgr.getAttackBaoJi(this);
//                 o = this.sgbaojilv + t.baojijilv;
//                 n = this.sgbaojia + t.baojijiacheng;
//                 i = !1;
//                 if (Math.random() <= o) {
//                     i = !0;
//                     e *= n;
//                 }
//                 cc.tween(this.playimg.node)
//                     .to(0.1, {
//                         scaleY: 1.1
//                     })
//                     .to(0.1, {
//                         scaleY: 1
//                     })
//                     .start();
//                 $gameGlobalVariable.GameGlobalVariable.addMoveBullet({
//                     attack: e,
//                     playerId: this,
//                     playerLevel: this.playerInfo.equipLevel,
//                     isbaoji: i
//                 });
//                 return [2];
//             });
//         });
//     };
//     t.prototype.createBulletBomb = function (e, t) {
//         return __awaiter(this, void 0, void 0, function () {
//             var o;
//             var n;
//             var i;
//             var a = this;
//             return __generator(this, function (r) {
//                 switch (r.label) {
//                     case 0:
//                         if ((o = $nodePoolMag.NodePoolMag.instance.getNode("bullet_2"))) {
//                             return [3, 2];
//                         } else {
//                             return [
//                                 4,
//                                 this._loadRes($bundleConfig.BundleNames.Game, "prefabs/bullet/bullet2", cc.Prefab)
//                             ];
//                         }
//                     case 1:
//                         n = r.sent();
//                         $nodePoolMag.NodePoolMag.instance.createNodeCount("bullet_2", 1, n);
//                         o = $nodePoolMag.NodePoolMag.instance.getNode("bullet_2");
//                         r.label = 2;
//                     case 2:
//                         i = this.auto_ui.node_sendpoint.convertToWorldSpaceAR(cc.v2());
//                         i = $gameGlobalVariable.GameGlobalVariable.languaNode.convertToNodeSpaceAR(i);
//                         o.x = i.x;
//                         o.y = i.y;
//                         $gameGlobalVariable.GameGlobalVariable.languaNode.addChild(o);
//                         this.scheduleOnce(function () {
//                             var n = o.getComponent($uI_BulletBomb.default);
//                             var i = $buffMag.BuffMgr.getAttackBaoJi(a);
//                             var r = a.sgbaojilv + i.baojijilv;
//                             var c = a.sgbaojia + i.baojijiacheng;
//                             var s = !1;
//                             if (Math.random() <= r) {
//                                 s = !0;
//                                 e *= c;
//                             }
//                             n.initBullet(
//                                 {
//                                     attack: e,
//                                     playerId: a,
//                                     skinlevel: a.playerInfo.equipLevel,
//                                     isbaoji: s
//                                 },
//                                 t
//                             );
//                         });
//                         return [2];
//                 }
//             });
//         });
//     };
//     t.prototype.createBullet = function (e, t, o, n) {
//         return __awaiter(this, void 0, void 0, function () {
//             var i;
//             var a;
//             var r;
//             var c = this;
//             return __generator(this, function (s) {
//                 switch (s.label) {
//                     case 0:
//                         if ((i = $nodePoolMag.NodePoolMag.instance.getNode("bullet_1"))) {
//                             return [3, 2];
//                         } else {
//                             return [
//                                 4,
//                                 this._loadRes($bundleConfig.BundleNames.Game, "prefabs/bullet/bullet1", cc.Prefab)
//                             ];
//                         }
//                     case 1:
//                         a = s.sent();
//                         $nodePoolMag.NodePoolMag.instance.createNodeCount("bullet_1", 5, a);
//                         i = $nodePoolMag.NodePoolMag.instance.getNode("bullet_1");
//                         s.label = 2;
//                     case 2:
//                         r = this.auto_ui.node_sendpoint.convertToWorldSpaceAR(cc.v2());
//                         r = $gameGlobalVariable.GameGlobalVariable.bulletNode.convertToNodeSpaceAR(r);
//                         i.x = r.x;
//                         i.y = r.y;
//                         $gameGlobalVariable.GameGlobalVariable.bulletNode.addChild(i);
//                         this.scheduleOnce(function () {
//                             i.getComponent($uI_Bullet.default).initBullet(
//                                 {
//                                     attack: e,
//                                     playerId: c,
//                                     feixintype: o,
//                                     isbaoji: n
//                                 },
//                                 t
//                             );
//                         });
//                         return [2];
//                 }
//             });
//         });
//     };
//     t.prototype.setKuangRe = function (e) {
//         if (!this.kuangrePlayer || this.kuangrePlayer.node.uuid != e.node.uuid) {
//             this.kuangrePlayer = e;
//             var t = $excel.Excel.shuiguobuff(e.sgtianfuid);
//             this.kuangretime = t.bufftime;
//             $logManager.LogMgr.debug("设置狂热效果", this);
//             this.addKuangReEff();
//         }
//     };
//     t.prototype.addKuangReEff = function () {
//         return __awaiter(this, void 0, void 0, function () {
//             var e;
//             var t = this;
//             return __generator(this, function (o) {
//                 switch (o.label) {
//                     case 0:
//                         this.xiaolajiao.active = !0;
//                         this.kuangReEffNode = $nodePoolMag.NodePoolMag.instance.getNode("kuangre");
//                         return this.kuangReEffNode
//                             ? [3, 2]
//                             : [
//                                   4,
//                                   this._loadRes($bundleConfig.BundleNames.Game, "prefabs/effpre/UI_KuangRe", cc.Prefab)
//                               ];
//                     case 1:
//                         e = o.sent();
//                         $nodePoolMag.NodePoolMag.instance.createNodeCount("kuangre", 1, e);
//                         this.kuangReEffNode = $nodePoolMag.NodePoolMag.instance.getNode("kuangre");
//                         o.label = 2;
//                     case 2:
//                         this.kuangReEffNode.x = 0;
//                         this.kuangReEffNode.y = 0;
//                         this.kuangReParNode.addChild(this.kuangReEffNode);
//                         this.scheduleOnce(function () {
//                             t.kuangReEffNode.scale = 1;
//                         });
//                         return [2];
//                 }
//             });
//         });
//     };
//     t.prototype.cleanKuangReEff = function () {
//         if (this.kuangReEffNode) {
//             this.xiaolajiao.active = !1;
//             $nodePoolMag.NodePoolMag.instance.recycleNode("kuangre", this.kuangReEffNode);
//             this.kuangReEffNode = null;
//             this.kuangretime = 0;
//             this.offkuangretime = 0;
//         }
//     };
//     t.prototype.puasePlayer = function () {};
//     t.prototype.onUpdate = function (e) {
//         if (this.kuangrePlayer && !this.kuangreisOver) {
//             this.offkuangretime += e;
//             if (this.offkuangretime >= 1) {
//                 this.kuangretime -= 1;
//                 this.offkuangretime = 0;
//                 if (this.kuangretime <= 0) {
//                     $buffMag.BuffMgr.getKuangReOver()
//                         ? (this.kuangreisOver = !0)
//                         : (this.cleanKuangReEff(), (this.kuangrePlayer = null), (this.kuangretime = 0));
//                 }
//             }
//         }
//         if (!this.playerpuase) {
//             this.attacktime += e;
//             var t = $buffMag.BuffMgr.playAttackJiaCheng(this, this.sgattackspeed, 2);
//             if (t < 0.2) {
//                 t = 5 == this.playerId ? 0.25 : 0.15;
//             }
//             t /= $gameGlobalVariable.GameGlobalVariable.jiasuState;
//             if (this.attacktime >= t) {
//                 this.startAttack();
//                 this.attacktime = 0;
//             }
//         }
//     };
//     t.prototype.startAttack = function () {
//         $buffMag.BuffMgr.addPlayerSendCount(this);
//         switch (this.sgattacktagtype) {
//             case 7:
//                 this.sendAttackMove();
//                 break;
//             case 6:
//                 this.sendAttackBomb();
//                 break;
//             case 5:
//                 break;
//             case 9:
//                 cc.tween(this.playimg.node)
//                     .to(0.1, {
//                         scaleY: 1.1
//                     })
//                     .to(0.1, {
//                         scaleY: 1
//                     })
//                     .start();
//                 $buffMag.BuffMgr.setKuangReBuff(this);
//                 break;
//             default:
//                 this.sendAttack();
//         }
//     };
//     __decorate([x($uI_Player_UIBindings.default)], t.prototype, "auto_ui", void 0);
//     __decorate([x()], t.prototype, "playerId", void 0);
//     __decorate([x(cc.Sprite)], t.prototype, "playimg", void 0);
//     __decorate([x(cc.Node)], t.prototype, "eff1", void 0);
//     __decorate([x(cc.Node)], t.prototype, "eff2", void 0);
//     return __decorate([E], t);
// })($resKeeper.default);
// exports.default = B;

// import {BundleNames} from "./BundleConfig";
// import {LogMgr} from "./LogManager";
// import ResKeeper from "./ResKeeper";
// import CommonUtils from "./CommonUtils";
// import UI_Player_UIBindings from "./UI_Player_UIBindings";
// import { PlayerDataMgr} from "./PlayerDataManager";
// import { ExcelUtil } from "./ExcelUtil";
// import { GameGlobalVariable } from "./GameGlobalVariable";
// import { NodePoolMag } from "./NodePoolMag";
// import UI_BulletBomb from "./UI_BulletBomb";
// import { BuffMgr } from "./BuffMag";
// import UI_MosterLogic  from "./UI_MosterLogic";
// import { Excel } from './Excel';
// import UI_Bullet from './UI_Bullet';

// const { ccclass, property } = cc._decorator;

// /**
//  * 建议类名: Player
//  */
// @ccclass
// class UI_Player extends ResKeeper {
//     @property(UI_Player_UIBindings)
//     auto_ui: any = null;

//     @property
//     playerId: number = 1;

//     @property(cc.Sprite)
//     playimg: cc.Sprite = null;

//     @property(cc.Node)
//     eff1: cc.Node = null;

//     @property(cc.Node)
//     eff2: cc.Node = null;

//     private sgattack: number = 0;
//     private sgattackspeed: number = 0;
//     private sgbaojilv: number = 0;
//     private sgbaojia: number = 0;
//     private sgattacktype: number = 1;
//     private sgattacktagtype: number = -1;
//     private sgtianfuid: number = -1;
//     private kuangrePlayer: any = null;
//     private buffid: number = -1;
//     private xiaolajiao: cc.Node = null;
//     private mosterNodes: cc.Node = null;
//     private playerInfo: any = null;
//     private kuangReParNode: cc.Node = null;
//     private leveliconspr: cc.Sprite = null;
//     private nowattackindex: number = 0;
//     private kuangReEffNode: cc.Node = null;
//     private attacktime: number = 0;
//     private kuangretime: number = 0;
//     private offkuangretime: number = 0;
//     private kuangreisOver: boolean = false;
//     private playerpuase: boolean = false;
//     private issend: boolean = false;
//     private ismove: boolean = false;

//     onEnable() {
//         this.xiaolajiao = this.node.getChildByName("xialajiao");
//         this.xiaolajiao.active = false;
//     }

//     onClickPlayer() { }

//     onDisable() {
//         this.cleanKuangReEff();
//         this.kuangrePlayer = null;
//         BuffMgr.clearPlayerSendCount(this);
//         this.attacktime = 0;
//     }

//     /**
//      * 初始化玩家信息
//      * @param e 怪物节点
//      * @param t 玩家信息
//      * 建议方法名: initializePlayerInfo
//      */
//     async initPlayerInfo(e: cc.Node, t: any) {
//         this.kuangReParNode = this.node.getChildByName("kuangreNode");
//         this.mosterNodes = e;
//         this.playerInfo = t;
//         if (this.eff1 && this.eff2) {
//             this.eff1.active = this.eff2.active = this.playerInfo.equipLevel === 4;
//         }
//         const o = 1000 + this.playerId;
//         const n = Excel.shuiguo(o);
//         LogMgr.debug("水果信息", n);
//         this.sgattack = n.attack;
//         this.sgattackspeed = n.attackspeed;
//         this.sgbaojilv = n.baojilv;
//         this.sgbaojia = n.baojivalue;
//         this.sgattacktype = n.attacktype;
//         this.sgattacktagtype = n.attackstate;
//         this.waibuleveladd();
//         this.hechengAdd();
//         this.sgtianfuid = n.talent;
//         await this.initUi();
//     }

//     /**
//      * 外部等级加成
//      * 建议方法名: addExternalLevel
//      */
//     waibuleveladd() {
//         if (this.playerInfo) {
//             const e = ExcelUtil.getSameData(Excel.shuiguolevel_all, "shuiguoId", this.playerId + 1000);
//             const t = PlayerDataMgr.GetEquipDataById(this.playerId + 1000).level;
//             let o = 0;
//             let n = 0;
//             for (let i = 0; i < e.length; i++) {
//                 if (i + 1 <= t && i > 0) {
//                     o += e[i - 1].addattack;
//                     n += e[i - 1].addAtkSpeed;
//                 }
//             }
//             this.sgattack += o;
//             this.sgattackspeed -= n;
//         }
//     }

//     /**
//      * 合成加成
//      * 建议方法名: addSynthesis
//      */
//     hechengAdd() {
//         if (this.playerInfo) {
//             const e = ExcelUtil.getSameData(Excel.shuiguohecheng_all, "shuiguoId", this.playerId + 1000)[this.playerInfo.equipLevel];
//             if (e) {
//                 this.sgattack += (this.sgattack * e.addattack) / 100;
//                 this.sgattackspeed /= (1 + e.addattackspeed / 100);
//             }
//         }
//     }

//     /**
//      * 获取当前合成等级
//      * 建议方法名: getCurrentSynthesisLevel
//      */
//     getNowHechengLevel() {
//         if (this.playerInfo) {
//             const e = ExcelUtil.getSameData(Excel.shuiguohecheng_all, "shuiguoId", this.playerId + 1000);
//             if (e) {
//                 return e[this.playerInfo.equipLevel];
//             }
//         }
//     }

//     /**
//      * 初始化UI
//      * 建议方法名: initializeUI
//      */
//     async initUi() {
//         if (this.playerInfo) {
//             const e = await this._loadRes(BundleNames.Common, `res/player/player${this.playerId}_${this.playerInfo.equipLevel + 1}`, cc.SpriteFrame);
//             this.playimg.spriteFrame = e;
//             this.leveliconspr = this.node.getChildByName("levelicon").getComponent(cc.Sprite);
//             const t = ["小牌子", "小牌子-1", "小牌子-2", "小牌子-3", "xiaowu"];
//             const o = await this._loadRes(BundleNames.Common, `res/player/${t[this.playerInfo.equipLevel]}`, cc.SpriteFrame);
//             this.leveliconspr.spriteFrame = o;
//         }
//     }

//     /**
//      * 获取攻击目标
//      * @param e 攻击类型
//      * 建议方法名: getAttackTarget
//      */
//     getAttackTag(e: number) {
//         var t = null;
//         if (!this.mosterNodes) {
//             if ((i = GameGlobalVariable.mosterNode).children.length > 0) {
//                 return i.children[0];
//             } else {
//                 return t;
//             }
//         }
//         if (this.mosterNodes.children.length > 0) {
//             var o = null;
//             switch (e) {
//                 case 4:
//                     for (var n = this.mosterNodes.children, i = null, a = 0; a < n.length; a++) {
//                         var r = n[a].getComponent(UI_MosterLogic);
//                         if (1 == r.nowmosterdata.boss) {
//                             i = r;
//                             break;
//                         }
//                     }
//                     if (i) {
//                         t = i.node;
//                     } else {
//                         if ((o = GameGlobalVariable.paixuMoster(this.mosterNodes)).length > 0) {
//                             t = o[0].script.node;
//                         }
//                     }
//                     break;
//                 case 1:
//                     if ((o = GameGlobalVariable.paixuMoster(this.mosterNodes)).length > 0) {
//                         t = o[0].script.node;
//                     }
//                     break;
//                 case 2:
//                     if ((o = GameGlobalVariable.paixuMoster(this.mosterNodes)).length > 0) {
//                         t = o[CommonUtils.limitInteger(0, o.length - 1)].script.node;
//                     }
//                     break;
//                 case 3:
//                     if ((o = GameGlobalVariable.paixuMoster(this.mosterNodes)).length > 0) {
//                         var c = o[this.nowattackindex];
//                         if (!c) {
//                             this.nowattackindex = 0;
//                             c = o[this.nowattackindex];
//                         }
//                         t = c.script.node;
//                         this.nowattackindex += 1;
//                     }
//                     if (!t) {
//                         var s = null;
//                         for (a = 0; a < o.length && !(s = o[a]); a++) { }
//                         if (s) {
//                             t = s.script.node;
//                         }
//                     }
//                     break;
//                 case 8:
//                 case 5:
//                     break;
//                 default:
//                     if ((o = GameGlobalVariable.paixuMoster(this.mosterNodes)).length > 0) {
//                         t = o[0].script.node;
//                     }
//             }
//         }
//         return t;
//     }

//     /**
//      * 发送攻击
//      * 建议方法名: sendAttack
//      */
//     sendAttack() {
//         const t = this.getAttackTag(this.sgattacktagtype);
//         if (t) {
//             cc.tween(this.playimg.node)
//                 .to(0.1, { scaleY: 1.3, scaleX: 1.1 })
//                 .to(0.1, { scale: 1 })
//                 .start();
//             const o = BuffMgr.playerAttackFangshiIng(this, this.sgattacktype);
//             let n = BuffMgr.playAttackJiaCheng(this, this.sgattack, 1);
//             const i = BuffMgr.getAttackBaoJi(this);
//             const a = this.sgbaojilv + i.baojijilv;
//             const r = this.sgbaojia + i.baojijiacheng;
//             let c = false;
//             if (Math.random() <= a) {
//                 c = true;
//                 n *= r;
//             }
//             if (BuffMgr.getLianXuAttack(this)) {
//                 this.scheduleOnce(() => {
//                     this.sendBullet(o, n, t, c);
//                 }, 0.1);
//             }
//             this.sendBullet(o, n, t, c);
//         }
//     }

//     /**
//      * 发送移动攻击
//      * 建议方法名: sendMoveAttack
//      */
//     sendAttackMove() {
//         if (this.mosterNodes.children.length >= 1) {
//             const e = BuffMgr.playAttackJiaCheng(this, this.sgattack, 1);
//             this.createBulletMove(e);
//         }
//     }

//     /**
//      * 发送爆炸攻击
//      * 建议方法名: sendBombAttack
//      */
//     sendAttackBomb() {
//         if (this.mosterNodes.children.length >= 1) {
//             cc.tween(this.playimg.node)
//                 .to(0.1, { scaleY: 1.1 })
//                 .to(0.1, { scaleY: 1 })
//                 .start();
//             const e = BuffMgr.playAttackJiaCheng(this, this.sgattack, 1);
//             const t = this.getBulletBombPos();
//             if (t) {
//                 this.createBulletBomb(e, t);
//             }
//         }
//     }

//     /**
//      * 发送子弹
//      * @param e 攻击方式
//      * @param t 攻击力
//      * @param o 目标节点
//      * @param n 是否暴击
//      * 建议方法名: sendBullet
//      */
//     sendBullet(e: number, t: number, o: cc.Node, n: boolean) {
//         switch (e) {
//             case 1:
//                 this.createBullet(t, o, 1, n);
//                 break;
//             case 2:
//                 const i = GameGlobalVariable.paixuMoster(this.mosterNodes);
//                 for (let a = 0; a < 3; a++) {
//                     const r = i[a];
//                     if (r) {
//                         this.createBullet(t, r.script.node, a + 1, n);
//                     }
//                 }
//         }
//     }

//     /**
//      * 获取爆炸子弹位置
//      * 建议方法名: getBulletBombPosition
//      */
//     getBulletBombPos() {
//         const e = GameGlobalVariable.paths.children;
//         const t: cc.Vec2[] = [];
//         for (let o = 0; o < e.length - 1; o++) {
//             const n = e[o];
//             const i = e[o + 1];
//             let a = 0;
//             if (o === 0) {
//                 a = -100;
//             }
//             let r = 0;
//             if (o + 1 === 5) {
//                 r = 100;
//             }
//             const c = CommonUtils.getRandomInt(n.x + a, i.x + r);
//             const s = CommonUtils.getRandomInt(n.y, i.y);
//             t.push(cc.v2(c,s));
//         }
//         return t[CommonUtils.getRandomInt(0, t.length - 1)];
//     }

//     /**
//      * 创建移动子弹
//      * @param e 攻击力
//      * 建议方法名: createMoveBullet
//      */
//     async createBulletMove(e: number) {
//         const t = BuffMgr.getAttackBaoJi(this);
//         const o = this.sgbaojilv + t.baojijilv;
//         const n = this.sgbaojia + t.baojijiacheng;
//         let i = false;
//         if (Math.random() <= o) {
//             i = true;
//             e *= n;
//         }
//         cc.tween(this.playimg.node)
//             .to(0.1, { scaleY: 1.1 })
//             .to(0.1, { scaleY: 1 })
//             .start();
//         GameGlobalVariable.addMoveBullet({
//             attack: e,
//             playerId: this,
//             playerLevel: this.playerInfo.equipLevel,
//             isbaoji: i
//         });
//     }

//     /**
//      * 创建爆炸子弹
//      * @param e 攻击力
//      * @param t 位置
//      * 建议方法名: createBombBullet
//      */
//     async createBulletBomb(e: number, t: cc.Vec2) {
//         let o = NodePoolMag.instance.getNode("bullet_2");
//         if (!o) {
//             const n = await this._loadRes(BundleNames.Game, "prefabs/bullet/bullet2", cc.Prefab);
//             NodePoolMag.instance.createNodeCount("bullet_2", 1, n);
//             o = NodePoolMag.instance.getNode("bullet_2");
//         }
//         let i = this.auto_ui.node_sendpoint.convertToWorldSpaceAR(cc.v2());
//         i = GameGlobalVariable.languaNode.convertToNodeSpaceAR(i);
//         o.x = i.x;
//         o.y = i.y;
//         GameGlobalVariable.languaNode.addChild(o);
//         this.scheduleOnce(() => {
//             const n = o.getComponent(UI_BulletBomb);
//             const i = BuffMgr.getAttackBaoJi(this);
//             const r = this.sgbaojilv + i.baojijilv;
//             const c = this.sgbaojia + i.baojijiacheng;
//             let s = false;
//             if (Math.random() <= r) {
//                 s = true;
//                 e *= c;
//             }
//             n.initBullet({
//                 attack: e,
//                 playerId: this,
//                 skinlevel: this.playerInfo.equipLevel,
//                 isbaoji: s
//             }, t);
//         });
//     }

//     /**
//      * 创建子弹
//      * @param e 攻击力
//      * @param t 目标节点
//      * @param o 飞行类型
//      * @param n 是否暴击
//      * 建议方法名: createBullet
//      */
//     async createBullet(e: number, t: cc.Node, o: number, n: boolean) {
//         let i = NodePoolMag.instance.getNode("bullet_1");
//         if (!i) {
//             const a = await this._loadRes(BundleNames.Game, "prefabs/bullet/bullet1", cc.Prefab);
//             NodePoolMag.instance.createNodeCount("bullet_1", 5, a);
//             i = NodePoolMag.instance.getNode("bullet_1");
//         }
//         let r = this.auto_ui.node_sendpoint.convertToWorldSpaceAR(cc.v2());
//         r = GameGlobalVariable.bulletNode.convertToNodeSpaceAR(r);
//         i.x = r.x;
//         i.y = r.y;
//         GameGlobalVariable.bulletNode.addChild(i);
//         this.scheduleOnce(() => {
//             i.getComponent(UI_Bullet).initBullet({
//                 attack: e,
//                 playerId: this,
//                 feixintype: o,
//                 isbaoji: n
//             }, t);
//         });
//     }

//     /**
//      * 设置狂热效果
//      * @param e 玩家
//      * 建议方法名: setFrenzyEffect
//      */
//     setKuangRe(e: any) {
//         if (!this.kuangrePlayer || this.kuangrePlayer.node.uuid !== e.node.uuid) {
//             this.kuangrePlayer = e;
//             const t = Excel.shuiguobuff(e.sgtianfuid);
//             this.kuangretime = t.bufftime;
//             LogMgr.debug("设置狂热效果", this);
//             this.addKuangReEff();
//         }
//     }

//     /**
//      * 添加狂热效果
//      * 建议方法名: addFrenzyEffect
//      */
//     async addKuangReEff() {
//         this.xiaolajiao.active = true;
//         this.kuangReEffNode = NodePoolMag.instance.getNode("kuangre");
//         if (!this.kuangReEffNode) {
//             const e = await this._loadRes(BundleNames.Game, "prefabs/effpre/UI_KuangRe", cc.Prefab);
//             NodePoolMag.instance.createNodeCount("kuangre", 1, e);
//             this.kuangReEffNode = NodePoolMag.instance.getNode("kuangre");
//         }
//         this.kuangReEffNode.x = 0;
//         this.kuangReEffNode.y = 0;
//         this.kuangReParNode.addChild(this.kuangReEffNode);
//         this.scheduleOnce(() => {
//             this.kuangReEffNode.scale = 1;
//         });
//     }

//     /**
//      * 清除狂热效果
//      * 建议方法名: clearFrenzyEffect
//      */
//     cleanKuangReEff() {
//         if (this.kuangReEffNode) {
//             this.xiaolajiao.active = false;
//             NodePoolMag.instance.recycleNode("kuangre", this.kuangReEffNode);
//             this.kuangReEffNode = null;
//             this.kuangretime = 0;
//             this.offkuangretime = 0;
//         }
//     }

//     puasePlayer() { }

//     /**
//      * 更新方法
//      * @param dt 时间间隔
//      * 建议方法名: update
//      */
//     onUpdate(dt: number) {
//         if (this.kuangrePlayer && !this.kuangreisOver) {
//             this.offkuangretime += dt;
//             if (this.offkuangretime >= 1) {
//                 this.kuangretime -= 1;
//                 this.offkuangretime = 0;
//                 if (this.kuangretime <= 0) {
//                     if (BuffMgr.getKuangReOver()) {
//                         this.kuangreisOver = true;
//                     } else {
//                         this.cleanKuangReEff();
//                         this.kuangrePlayer = null;
//                         this.kuangretime = 0;
//                     }
//                 }
//             }
//         }
//         if (!this.playerpuase) {
//             this.attacktime += dt;
//             let t = BuffMgr.playAttackJiaCheng(this, this.sgattackspeed, 2);
//             if (t < 0.2) {
//                 t = this.playerId === 5 ? 0.25 : 0.15;
//             }
//             t /= GameGlobalVariable.jiasuState;
//             if (this.attacktime >= t) {
//                 this.startAttack();
//                 this.attacktime = 0;
//             }
//         }
//     }

//     /**
//      * 开始攻击
//      * 建议方法名: startAttack
//      */
//     startAttack() {
//         BuffMgr.addPlayerSendCount(this);
//         switch (this.sgattacktagtype) {
//             case 7:
//                 this.sendAttackMove();
//                 break;
//             case 6:
//                 this.sendAttackBomb();
//                 break;
//             case 5:
//                 break;
//             case 9:
//                 cc.tween(this.playimg.node)
//                     .to(0.1, { scaleY: 1.1 })
//                     .to(0.1, { scaleY: 1 })
//                     .start();
//                 BuffMgr.setKuangReBuff(this);
//                 break;
//             default:
//                 this.sendAttack();
//         }
//     }
// }

// export default UI_Player;

import { BundleNames } from "./BundleConfig";
import { LogMgr } from "./LogManager";
import ResKeeper from "./ResKeeper";
import CommonUtils from "./CommonUtils";
import UIPlayerUIBindings from "./UI_Player_UIBindings";
import { PlayerDataMgr } from "./PlayerDataManager";
import { ExcelUtil } from "./ExcelUtil";
import { GameGlobalVariable } from "./GameGlobalVariable";
import { NodePoolMag } from "./NodePoolMag";
import ViewBulletBomb from "./UI_BulletBomb";
import { BuffMgr } from "./BuffMag";
import ViewMosterLogic from "./UI_MosterLogic";
import { Excel } from './Excel';
import ViewBullet from './UI_Bullet';

const { ccclass, property } = cc._decorator;

/**
 * 建议类名: Player
 */
@ccclass
class ViewPlayer extends ResKeeper {
    @property(UIPlayerUIBindings)
    auto_ui: any = null;

    @property
    playerId: number = 1;

    @property(cc.Sprite)
    playimg: cc.Sprite = null;

    @property(cc.Node)
    eff1: cc.Node = null;

    @property(cc.Node)
    eff2: cc.Node = null;

    public sgattack: number = 0;
    public sgattackspeed: number = 0;
    public sgbaojilv: number = 0;
    public sgbaojia: number = 0;
    public sgattacktype: number = 1;
    public sgattacktagtype: number = -1;
    public sgtianfuid: number = -1;
    private kuangrePlayer: any = null;
    private buffId: number = -1;
    private xiaolajiao: cc.Node = null;
    private mosterNodes: cc.Node = null;
    private playerInfo: any = null;
    private kuangReParNode: cc.Node = null;
    private levelIconSpr: cc.Sprite = null;
    private nowAttackIndex: number = 0;
    private kuangReEffNode: cc.Node = null;
    private attackTime: number = 0;
    private kuangReTime: number = 0;
    private offKuangReTime: number = 0;
    private kuangReIsOver: boolean = false;
    private playerPause: boolean = false;
    private isSend: boolean = false;
    private isMove: boolean = false;

    onEnable() {
        this.xiaolajiao = this.node.getChildByName("xialajiao");
        this.xiaolajiao.active = false;
    }

    onClickPlayer() { }

    onDisable() {
        this.clearFrenzyEffect();
        this.kuangrePlayer = null;
        BuffMgr.clearPlayerSendCount(this);
        this.attackTime = 0;
    }

    /**
     * 初始化玩家信息
     * @param e 怪物节点
     * @param t 玩家信息
     * 建议方法名: initializePlayerInfo
     */
    async initializePlayerInfo(e: cc.Node, t: any) {
        this.kuangReParNode = this.node.getChildByName("kuangreNode");
        this.mosterNodes = e;
        this.playerInfo = t;
        if (this.eff1 && this.eff2) {
            this.eff1.active = this.eff2.active = this.playerInfo.equipLevel === 4;
        }
        const fruitId = 1000 + this.playerId;
        const fruitInfo = Excel.shuiguo(fruitId);
        LogMgr.debug("水果信息", fruitInfo);
        this.sgattack = fruitInfo.attack;
        this.sgattackspeed = fruitInfo.attackspeed;
        this.sgbaojilv = fruitInfo.baojilv;
        this.sgbaojia = fruitInfo.baojivalue;
        this.sgattacktype = fruitInfo.attacktype;
        this.sgattacktagtype = fruitInfo.attackstate;
        this.addExternalLevel();
        this.addSynthesis();
        this.sgtianfuid = fruitInfo.talent;
        await this.initUI();
    }

    /**
     * 外部等级加成
     * 建议方法名: addExternalLevel
     */
    addExternalLevel() {
        if (this.playerInfo) {
            const levelData = ExcelUtil.getMatchingData(Excel.shuiguolevel_all, "shuiguoId", this.playerId + 1000);
            const equipLevel = PlayerDataMgr.getEquipDataById(this.playerId + 1000).level;
            let totalAttack = 0;
            let totalAttackSpeed = 0;
            for (let i = 0; i < levelData.length; i++) {
                if (i + 1 <= equipLevel && i > 0) {
                    totalAttack += levelData[i - 1].addattack;
                    totalAttackSpeed += levelData[i - 1].addAtkSpeed;
                }
            }
            this.sgattack += totalAttack;
            this.sgattackspeed -= totalAttackSpeed;
        }
    }

    /**
     * 合成加成
     * 建议方法名: addSynthesis
     */
    addSynthesis() {
        if (this.playerInfo) {
            const synthesisData = ExcelUtil.getMatchingData(Excel.shuiguohecheng_all, "shuiguoId", this.playerId + 1000)[this.playerInfo.equipLevel];
            if (synthesisData) {
                this.sgattack += (this.sgattack * synthesisData.addattack) / 100;
                this.sgattackspeed /= (1 + synthesisData.addattackspeed / 100);
            }
        }
    }

    /**
     * 获取当前合成等级
     * 建议方法名: getCurrentSynthesisLevel
     */
    getCurrentSynthesisLevel() {
        if (this.playerInfo) {
            const synthesisData = ExcelUtil.getMatchingData(Excel.shuiguohecheng_all, "shuiguoId", this.playerId + 1000);
            if (synthesisData) {
                return synthesisData[this.playerInfo.equipLevel];
            }
        }
    }

    /**
     * 初始化UI
     * 建议方法名: initializeUI
     */
    async initUI() {
        if (this.playerInfo) {
            const spriteFrame = await this._loadRes(BundleNames.Common, `res/player/player${this.playerId}_${this.playerInfo.equipLevel + 1}`, cc.SpriteFrame);
            this.playimg.spriteFrame = spriteFrame;
            this.levelIconSpr = this.node.getChildByName("levelicon").getComponent(cc.Sprite);
            const levelIconNames = ["小牌子", "小牌子-1", "小牌子-2", "小牌子-3", "xiaowu"];
            const levelIconSpriteFrame = await this._loadRes(BundleNames.Common, `res/player/${levelIconNames[this.playerInfo.equipLevel]}`, cc.SpriteFrame);
            this.levelIconSpr.spriteFrame = levelIconSpriteFrame;
        }
    }

    /**
     * 获取攻击目标
     * @param e 攻击类型
     * 建议方法名: getAttackTarget
     */
    getAttackTarget(e: number) {
        let targetNode: cc.Node = null;
        if (!this.mosterNodes) {
            const globalMosterNode = GameGlobalVariable.mosterNode;
            if (globalMosterNode.children.length > 0) {
                return globalMosterNode.children[0];
            } else {
                return targetNode;
            }
        }
        if (this.mosterNodes.children.length > 0) {
            let sortedMonsters;
            switch (e) {
                case 4:
                    sortedMonsters = this.mosterNodes.children;
                    let bossMonster = null;
                    for (let a = 0; a < sortedMonsters.length; a++) {
                        const monsterLogic = sortedMonsters[a].getComponent(ViewMosterLogic);
                        if (monsterLogic.nowmosterdata.boss === 1) {
                            bossMonster = monsterLogic;
                            break;
                        }
                    }
                    targetNode = bossMonster ? bossMonster.node : sortedMonsters[0].script.node;
                    break;
                case 1:
                    sortedMonsters = GameGlobalVariable.sortMonsters(this.mosterNodes);
                    targetNode = sortedMonsters.length > 0 ? sortedMonsters[0].script.node : null;
                    break;
                case 2:
                    sortedMonsters = GameGlobalVariable.sortMonsters(this.mosterNodes);
                    targetNode = sortedMonsters.length > 0 ? sortedMonsters[CommonUtils.limitIntegerInRange(0, sortedMonsters.length - 1)].script.node : null;
                    break;
                case 3:
                    sortedMonsters = GameGlobalVariable.sortMonsters(this.mosterNodes);
                    let currentMonster = sortedMonsters[this.nowAttackIndex];
                    if (!currentMonster) {
                        this.nowAttackIndex = 0;
                        currentMonster = sortedMonsters[this.nowAttackIndex];
                    }
                    targetNode = currentMonster ? currentMonster.script.node : null;
                    this.nowAttackIndex += 1;
                    break;
                case 8:
                case 5:
                    break;
                default:
                    sortedMonsters = GameGlobalVariable.sortMonsters(this.mosterNodes);
                    targetNode = sortedMonsters.length > 0 ? sortedMonsters[0].script.node : null;
            }
        }
        return targetNode;
    }

    /**
     * 发送攻击
     * 建议方法名: sendAttack
     */
    sendAttack() {
        const target = this.getAttackTarget(this.sgattacktagtype);
        if (target) {
            cc.tween(this.playimg.node)
                .to(0.1, { scaleY: 1.3, scaleX: 1.1 })
                .to(0.1, { scale: 1 })
                .start();
            const attackMethod = BuffMgr.playerAttackModeInProgress(this, this.sgattacktype);
            let attackPower = BuffMgr.applyAttackBonus(this, this.sgattack, 1);
            const critical = BuffMgr.getAttackCritical(this);
            const criticalChance = this.sgbaojilv + critical.baojijilv;
            const criticalDamage = this.sgbaojia + critical.baojijiacheng;
            let isCritical = false;
            if (Math.random() <= criticalChance) {
                isCritical = true;
                attackPower *= criticalDamage;
            }
            if (BuffMgr.isContinuousAttack(this)) {
                this.scheduleOnce(() => {
                    this.sendBullet(attackMethod, attackPower, target, isCritical);
                }, 0.1);
            }
            this.sendBullet(attackMethod, attackPower, target, isCritical);
        }
    }

    /**
     * 发送移动攻击
     * 建议方法名: sendMoveAttack
     */
    sendMoveAttack() {
        if (this.mosterNodes.children.length >= 1) {
            const attackPower = BuffMgr.applyAttackBonus(this, this.sgattack, 1);
            this.createMoveBullet(attackPower);
        }
    }

    /**
     * 发送爆炸攻击
     * 建议方法名: sendBombAttack
     */
    sendBombAttack() {
        if (this.mosterNodes.children.length >= 1) {
            cc.tween(this.playimg.node)
                .to(0.1, { scaleY: 1.1 })
                .to(0.1, { scaleY: 1 })
                .start();
            const attackPower = BuffMgr.applyAttackBonus(this, this.sgattack, 1);
            const bombPosition = this.getBulletBombPosition();
            if (bombPosition) {
                this.createBombBullet(attackPower, bombPosition);
            }
        }
    }

    /**
     * 发送子弹
     * @param e 攻击方式
     * @param t 攻击力
     * @param o 目标节点
     * @param n 是否暴击
     * 建议方法名: sendBullet
     */
    sendBullet(e: number, t: number, o: cc.Node, n: boolean) {
        switch (e) {
            case 1:
                this.createBullet(t, o, 1, n);
                break;
            case 2:
                const sortedMonsters = GameGlobalVariable.sortMonsters(this.mosterNodes);
                for (let i = 0; i < 3; i++) {
                    const currentMonster = sortedMonsters[i];
                    if (currentMonster) {
                        this.createBullet(t, currentMonster.script.node, i + 1, n);
                    }
                }
        }
    }

    /**
     * 获取爆炸子弹位置
     * 建议方法名: getBulletBombPosition
     */
    getBulletBombPosition() {
        const pathNodes = GameGlobalVariable.paths.children;
        const positions: cc.Vec2[] = [];
        for (let i = 0; i < pathNodes.length - 1; i++) {
            const startNode = pathNodes[i];
            const endNode = pathNodes[i + 1];
            let startOffset = 0;
            let endOffset = 0;
            if (i === 0) startOffset = -100;
            if (i + 1 === 5) endOffset = 100;
            const x = CommonUtils.getRandomInteger(startNode.x + startOffset, endNode.x + endOffset);
            const y = CommonUtils.getRandomInteger(startNode.y, endNode.y);
            positions.push(cc.v2(x, y));
        }
        return positions[CommonUtils.getRandomInteger(0, positions.length - 1)];
    }

    /**
     * 创建移动子弹
     * @param e 攻击力
     * 建议方法名: createMoveBullet
     */
    async createMoveBullet(e: number) {
        const critical = BuffMgr.getAttackCritical(this);
        const criticalChance = this.sgbaojilv + critical.baojijilv;
        const criticalDamage = this.sgbaojia + critical.baojijiacheng;
        let isCritical = false;
        if (Math.random() <= criticalChance) {
            isCritical = true;
            e *= criticalDamage;
        }
        cc.tween(this.playimg.node)
            .to(0.1, { scaleY: 1.1 })
            .to(0.1, { scaleY: 1 })
            .start();
        GameGlobalVariable.addMovingBullet({
            attack: e,
            playerId: this,
            playerLevel: this.playerInfo.equipLevel,
            isbaoji: isCritical
        });
    }

    /**
     * 创建爆炸子弹
     * @param e 攻击力
     * @param t 位置
     * 建议方法名: createBombBullet
     */
    async createBombBullet(e: number, t: cc.Vec2) {
        let bulletNode = NodePoolMag.instance.getNodeFromPool("bullet_2");
        if (!bulletNode) {
            const prefab = await this._loadRes(BundleNames.Game, "prefabs/bullet/bullet2", cc.Prefab);
            NodePoolMag.instance.createNodePool("bullet_2", 1, prefab);
            bulletNode = NodePoolMag.instance.getNodeFromPool("bullet_2");
        }
        let worldPos = this.auto_ui.node_sendpoint.convertToWorldSpaceAR(cc.v2());
        let nodeSpacePos = GameGlobalVariable.languaNode.convertToNodeSpaceAR(worldPos);
        bulletNode.x = nodeSpacePos.x;
        bulletNode.y = nodeSpacePos.y;
        GameGlobalVariable.languaNode.addChild(bulletNode);
        this.scheduleOnce(() => {
            const bulletBombComp = bulletNode.getComponent(ViewBulletBomb);
            const critical = BuffMgr.getAttackCritical(this);
            const criticalChance = this.sgbaojilv + critical.baojijilv;
            const criticalDamage = this.sgbaojia + critical.baojijiacheng;
            let isCritical = false;
            if (Math.random() <= criticalChance) {
                isCritical = true;
                e *= criticalDamage;
            }
            bulletBombComp.initializeBullet({
                attack: e,
                playerId: this,
                skinlevel: this.playerInfo.equipLevel,
                isbaoji: isCritical
            }, t);
        });
    }

    /**
     * 创建子弹
     * @param e 攻击力
     * @param t 目标节点
     * @param o 飞行类型
     * @param n 是否暴击
     * 建议方法名: createBullet
     */
    async createBullet(e: number, t: cc.Node, o: number, n: boolean) {
        let bulletNode = NodePoolMag.instance.getNodeFromPool("bullet_1");
        if (!bulletNode) {
            const prefab = await this._loadRes(BundleNames.Game, "prefabs/bullet/bullet1", cc.Prefab);
            NodePoolMag.instance.createNodePool("bullet_1", 5, prefab);
            bulletNode = NodePoolMag.instance.getNodeFromPool("bullet_1");
        }
        let worldPos = this.auto_ui.node_sendpoint.convertToWorldSpaceAR(cc.v2());
        let nodeSpacePos = GameGlobalVariable.bulletNode.convertToNodeSpaceAR(worldPos);
        bulletNode.x = nodeSpacePos.x;
        bulletNode.y = nodeSpacePos.y;
        GameGlobalVariable.bulletNode.addChild(bulletNode);
        this.scheduleOnce(() => {
            bulletNode.getComponent(ViewBullet).initializeBullet({
                attack: e,
                playerId: this,
                feixintype: o,
                isbaoji: n
            }, t);
        });
    }

    /**
     * 设置狂热效果
     * @param e 玩家
     * 建议方法名: setFrenzyEffect
     */
    setFrenzyEffect(e: any) {
        if (!this.kuangrePlayer || this.kuangrePlayer.node.uuid !== e.node.uuid) {
            this.kuangrePlayer = e;
            const frenzyData = Excel.shuiguobuff(e.sgtianfuid);
            this.kuangReTime = frenzyData.bufftime;
            LogMgr.debug("设置狂热效果", this);
            this.addFrenzyEffect();
        }
    }

    /**
     * 添加狂热效果
     * 建议方法名: addFrenzyEffect
     */
    async addFrenzyEffect() {
        this.xiaolajiao.active = true;
        this.kuangReEffNode = NodePoolMag.instance.getNodeFromPool("kuangre");
        if (!this.kuangReEffNode) {
            const prefab = await this._loadRes(BundleNames.Game, "prefabs/effpre/UI_KuangRe", cc.Prefab);
            NodePoolMag.instance.createNodePool("kuangre", 1, prefab);
            this.kuangReEffNode = NodePoolMag.instance.getNodeFromPool("kuangre");
        }
        this.kuangReEffNode.x = 0;
        this.kuangReEffNode.y = 0;
        this.kuangReParNode.addChild(this.kuangReEffNode);
        this.scheduleOnce(() => {
            this.kuangReEffNode.scale = 1;
        });
    }

    /**
     * 清除狂热效果
     * 建议方法名: clearFrenzyEffect
     */
    clearFrenzyEffect() {
        if (this.kuangReEffNode) {
            this.xiaolajiao.active = false;
            NodePoolMag.instance.recycleNodeToPool("kuangre", this.kuangReEffNode);
            this.kuangReEffNode = null;
            this.kuangReTime = 0;
            this.offKuangReTime = 0;
        }
    }

    puasePlayer() { }

    /**
     * 更新方法
     * @param dt 时间间隔
     * 建议方法名: update
     */
    onUpdate(dt: number) {
        if (this.kuangrePlayer && !this.kuangReIsOver) {
            this.offKuangReTime += dt;
            if (this.offKuangReTime >= 1) {
                this.kuangReTime -= 1;
                this.offKuangReTime = 0;
                if (this.kuangReTime <= 0) {
                    if (BuffMgr.isFrenzyOver()) {
                        this.kuangReIsOver = true;
                    } else {
                        this.clearFrenzyEffect();
                        this.kuangrePlayer = null;
                        this.kuangReTime = 0;
                    }
                }
            }
        }
        if (!this.playerPause) {
            this.attackTime += dt;
            let totalAttackSpeed = BuffMgr.applyAttackBonus(this, this.sgattackspeed, 2);
            if (totalAttackSpeed < 0.2) {
                totalAttackSpeed = this.playerId === 5 ? 0.25 : 0.15;
            }
            totalAttackSpeed /= GameGlobalVariable.jiasuState;
            if (this.attackTime >= totalAttackSpeed) {
                this.startAttack();
                this.attackTime = 0;
            }
        }
    }

    /**
     * 开始攻击
     * 建议方法名: startAttack
     */
    startAttack() {
        BuffMgr.addPlayerSendCount(this);
        switch (this.sgattacktagtype) {
            case 7:
                this.sendMoveAttack();
                break;
            case 6:
                this.sendBombAttack();
                break;
            case 5:
                break;
            case 9:
                cc.tween(this.playimg.node)
                    .to(0.1, { scaleY: 1.1 })
                    .to(0.1, { scaleY: 1 })
                    .start();
                BuffMgr.setFrenzyBuff(this);
                break;
            default:
                this.sendAttack();
        }
    }
}

export default ViewPlayer;
